package com.mbv5.xml;

import java.io.InputStream;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * Created by qiao on 2017/1/7.
 */
public class XpathUtils {


    public static void main(String[] args) throws Exception {
        String path = "mybatis-config.xml";
        InputStream inputStream = ResourceUtils.load(path);
        Document document = DocumentUtils.parse(inputStream);
        XPath xpath = XPathFactory.newInstance().newXPath();
        Element element = document.getDocumentElement();
        XPathParser xPathParser = new XPathParser(document, xpath);
        XNode xnode = xPathParser.evalNode("/configuration");
        XNode setNode = xnode.evalNode("settings");
        System.out.println(setNode.getChildrenAsProperties());
        System.out.println("over");
    }
}
